<template>
  <div class="application-table">
    <div class="flex align-center justify-content-space-between" style="margin-bottom: 20px">
        <div class="title">党费使用申请</div>
        <el-button  type="primary" icon="Plus">新增申请</el-button>
    </div>
    <el-table :data="applications"  style="width: 100%">
      <el-table-column prop="item" label="申请事项" align="center" />
      <el-table-column prop="amount" label="申请金额" align="center" />
      <el-table-column prop="department" label="申请支部" align="center" />
      <el-table-column prop="date" label="申请时间" align="center" />
      <el-table-column prop="status" label="审批状态" align="center">
        <template #default="{ row }">
          <div :class="getStatusClass(row.status)">
            {{ getStatusText(row.status) }}
          </div>
        </template>
      </el-table-column>

      <el-table-column label="操作" align="center">
        <template #default="{ row }">
          <el-button link type="primary" @click="viewDetail(row)">查看</el-button>
          <el-button link @click="cancelApplication(row)">撤销</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script setup>
import { ElButton } from 'element-plus'
import 'element-plus/dist/index.css'
import { Search,Plus } from '@element-plus/icons-vue'
const applications = ref([
  {
    item: '购买党史学习资料',
    amount: '¥1,200.00',
    department: '内科支部',
    date: '2025-08-05',
    status: 0
  },
  {
    item: '慰问困难党员',
    amount: '¥800.00',
    department: '外科支部',
    date: '2025-07-20',
    status: 1
  },
  {
    item: '党建活动经费',
    amount: '¥2,000.00',
    department: '行政支部',
    date: '2025-06-15',
    status: 2
  }
]);
const getStatusText = (status) => {
  switch (status) {
    case 0:
      return '已批准';
    case 1:
      return '审批中';
    case 2:
      return '已拒绝';
    default:
      return '未知审批状态';
  }
};
const getStatusClass = (status) => {
  switch (status) {
    case 0: // 未缴费
      return 'status-unpaid';
    case 1: // 部分缴费
      return 'status-partial';
    case 2: // 已缴费
      return 'status-paid';
    default:
      return '';
  }
};


const viewDetail = (row) => {
  console.log('查看详情:', row);
};
const cancelApplication = (row) => {
  console.log('撤销申请:', row);
};
const payRecord = ref('');
</script>

<style scoped lang="scss">
.application-table {
  margin-top: 20px;
  padding:20px 20px 40px 20px;
  background-color: #FFFFFF;
  border-radius: 10px;
  .title {
    font-size: 18px;
    color: #333333;
    font-weight: bolder;
  }
  .status-unpaid {
    background-color: #FEE2E2;
    color: #A12C2C;
    width: fit-content;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: bolder;
    margin: 0 auto;
  }
  .status-partial {
    background-color: #FEF9C3;
    color: #A27639;
    width: fit-content;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: bolder;
    margin: 0 auto;
  }
  .status-paid {
    background-color: #DCFCE7;
    color: #2E7749;
    width: fit-content;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: bolder;
    margin: 0 auto;
  }
}

</style>
